/* this class draws everything
*/

#ifndef _GRAPHICS_H
#define _GRAPHICS_H

#include <string>
#include <map>
#include "common\GLApp.h"
#include "core\GameState.h"
#include "core\TextureManager.h"
#include "core\Text.h"
#include "core\TextBox.h"
#include "game\Map.h"
#include "game\Player.h"
#include "common\Random.h"
#include "game\MapGenerator.h"

/* to add a texture:
- toss it into the res directory
*/


class Camera
{
public:
	double anglex;
	double angley;
	Camera();
	double posx;
	double posy;
	double posz;
	void zoom(double z, double clampMin = -DBL_MAX, double clampMax = DBL_MAX);
	void vert(double v, double clampMin = -DBL_MAX, double clampMax = DBL_MAX);
	void hori(double h, double clampMin = -DBL_MAX, double clampMax = DBL_MAX);
	void lookx(double look, double clampMin = -DBL_MAX, double clampMax = DBL_MAX);
	void looky(double look, double clampMin = -DBL_MAX, double clampMax = DBL_MAX);
};


class Graphics : public GameState
{
public:
	Camera m_Camera;
  void enterState();
  void exitState();
	bool init();
	void deinit();
	void draw();
  APP_MSG update(DWORD milliseconds, Keys* keys, Mouse* mouse);
  void setMap(int level);
  void click(unsigned int x, unsigned int y);
  void keyPress(Keys keys, double speedFactor); 
  static Graphics* getInstance(StateManager* manager);
protected:
  Graphics(StateManager* manager);
private:
	TextureManager m_textureManager;  
  MapGenerator m_mapGenerator;
  FontManager* m_fontManager;
	bool loadTextures();
	void drawMap();
  void drawOverlay();
  void picking();  
  typedef std::map<std::string, glTexture> texMap;
	texMap textureMap;  
  Player m_player;
  TextBox m_textBox;
  Map* m_currentMap;
  int m_currentLevel;
  Map* m_maps[256];  
  Random RNG;
  double m_timeDelta;
};

#endif